package com.knowledge.graph.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.knowledge.graph.model.entity.CourseAndUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description: 对课程-教师表的数据库操作
 * @author jiwenlong
 * @date 2023/11/8 19:45
 * @version 1.0
 */
@Mapper
public interface CourseAndUserMapper extends BaseMapper<CourseAndUser> {

    @Delete("delete from course_and_user where course_id = #{courseID}")
    public int deleteByCourseId(Integer courseID);

    @Select("select course_id from course_and_user where user_id = #{userID}")
    public List<Long> selectByTeacherId(Long userID);

    @Select("select count(*) from course_and_user where course_id = #{courseId} and user_id = #{userId}")
    int selectByCourseAndUser(CourseAndUser courseAndUser);
}
